//detail.js
//获取应用实例
var app = getApp()
Page({
  data: {
    
  },
  //事件处理函数
  onLoad:function (options) {
  	var that = this;
    // 装载“加载中”动态效果
    this.setData({
      loadModal: true
    })

    console.log('detail.js')
    console.log(options)

    wx.request({
      url: 'https://duzicong.cn/Courier/getAPI.php', //得到物流跟踪信息
      data: {
        num:options['postid']
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        console.log(res.data)
        that.setData({
          company:res.data.company,
          nu:res.data.nu,
          messages:res.data.messages
        })
        if (res.data.messages){
          // 如果加载成功，则去除加载中动态效果
          that.setData({
            loadModal : false
          })
        }else{
          //如果加载失败，则在4秒后去除动态效果
          setTimeout(() => {
            that.setData({
              loadModal: false
            })
          }, 4000)
        }
      }
    })
  },
  copyId: function (e) {
    console.log(e)
    var that = this
    wx.setClipboardData({
      data: that.data.nu,
      success(res) {
        wx.getClipboardData({
          success(res) {
            console.log(res.data) // data
            wx.showToast({
              title: '复制成功'
            })
          }
        })
      }
    })
  }

})